package cn.tedu.store.service;

import cn.tedu.store.entity.User;
import cn.tedu.store.service.ex.InsertException;
import cn.tedu.store.service.ex.PasswordErrorException;
import cn.tedu.store.service.ex.UpdateException;
import cn.tedu.store.service.ex.UserNameDuplicateException;
import cn.tedu.store.service.ex.UserNotFoundException;

/**
 * 处理用户数据的业务层接口：使用接口使调用该方法的类不会过度依赖实现类，好处在于解耦
 * @author Administrator
 *
 */
public interface IUserService {
	/**
	 * 用户注册
	 * @param user 用户数据
	 * @throws UserNameDuplicateException 用户名冲突异常
	 * @throws InsertException 插入数据异常
	 */
	void reg(User user) throws UserNameDuplicateException,InsertException;
	
	/**
	 * 用户登录
	 * @param username
	 * @param password
	 * @return
	 * @throws UserNotFoundException 用户名不存在
	 * @throws PasswordErrorException 密码错误
	 */
	User login(String username,String password) throws UserNotFoundException,PasswordErrorException;


	/**
	 * 修改密码
	 * @param uid 用户id
	 * @param oldPassword 旧密码
	 * @param newPassword 新密码
	 * @throws UserNotFoundException 用户名不存在
	 * @throws PasswordErrorException 密码错误
	 * @throws UpdateException 修改密码异常
	 */
	void changePassword(
			Integer uid,
			String oldPassword,
			String newPassword
			) throws UserNotFoundException,PasswordErrorException,UpdateException;  
	
	/**
	 * 修改头像
	 * @param uid
	 * @param avatar
	 * @throws UserNotFoundException
	 * @throws UpdateException
	 */
	void changeAvatar(Integer uid,String avatar) throws UserNotFoundException,UpdateException;
	
	
	/**
	 * 修改用户资料
	 * @param user
	 * @throws UserNotFoundException
	 * @throws UpdateException
	 */
	void changeInfo(User user) throws UserNotFoundException,UpdateException;
	
	/**
	 * 根据uid查询用户信息，修改资料前，是显示的原来的信息的，所以这里需要查出来
	 * @param uid
	 * @return
	 * @throws UserNotFoundException
	 */
	User getByUid(Integer uid) throws UserNotFoundException;
	
}
